<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        div {
            margin: 20 0;
            text-align: center;
        }

        h1 {
            margin: 0 auto;
            text-align: center;
        }
    </style>
</head>

<body>
    <h1>注册</h1>
    <div>
        <input type="text" name="user" id="user" placeholder="用户名">
    </div>
    <div>
        <input type="password" name="pass" id="pass" placeholder="密码">
    </div>
    <div>
        <button class="button">注册</button>
    </div>
</body>

</html>
<script src="../js/ajax.js"></script>
<script>
    function $(e) { return document.querySelector(e) }
    $(".button").onclick = () => {

        obj.post({
            url: "/registry",

            text: {
                user: $("#user").value,
                pass: $("#pass").value,

            },
            hed: {

            },
            callback(data) {
                console.log(data);
                switch (data) {
                    case "001": alert("注册成功")
                    location.href = "http://localhost:3000/public/cook/html/login.html"
                    ; break
                    case "002": alert("账号已存在"); break

                }

            }
        })

    }


</script>